package com.test.qpbgboot.user.service;

import com.test.qpbgboot.base.exception.ServiceException;
import com.test.qpbgboot.base.response.ResultStatus;
import com.test.qpbgboot.base.utils.JwtTokenUtils;
import com.test.qpbgboot.user.pojo.dto.*;
import com.test.qpbgboot.user.pojo.vo.UserFansVO;
import com.test.qpbgboot.user.pojo.vo.UserFollowingVO;
import com.test.qpbgboot.user.pojo.vo.UserVO;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;

public interface UserService {
    void reg(UserRegParam userRegParam);

    void passwordChange(UserPasswordParam userPasswordParam);

    void userLogOff(Long userId);

    void userSave(@Valid UserSaveParam userSaveParam);

    UserVO userSelect(Long userId);

    void userFollow(@Valid UserFollowParam userFollowParam);

    void userUnfollow(@Valid UserFollowParam userFollowParam);

    List<UserFollowingVO> followingSelect(Long userId);

    List<UserFansVO> fansSelect(Long userId);

    UserVO login(@Valid UserLoginParam userLoginParam);

//    UserVO wechatLogin(String code);

    static void checkUserVOId(String token, Long id) {
        UserVO userVO = JwtTokenUtils.parseJWT(token, UserVO.class);
        if (userVO == null || userVO.getId() == null
                || !id.equals(userVO.getId())) {
            throw new ServiceException(ResultStatus.INVALID_TOKEN);
        }
    }

    UserVO phoneLogin(@Valid PhoneLoginParam phoneLoginParam);

    boolean wxCheck(String signature, String timestamp, String nonce, String echostr);

    Map<String, String> getQrCode() throws UnsupportedEncodingException;

    void redirect(String code, String state, HttpServletResponse response);

    Map<String, Object> checkLogin(String state);

    UserVO getUserInfoByWxOpenId(String token);
}
